#include "Shader.hpp"

void		Shader::use()
{
	glUseProgram(this->_programId);
}

void		Shader::disable()
{
	glUseProgram(0);
}

void		Shader::sendUniformData(const char* varName, float value)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform1f(uniformId, value);
}

void		Shader::sendUniformData(const char* varName, float v1, float v2)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform2f(uniformId, v1, v2);
}

void		Shader::sendUniformData(const char* varName, float v1, float v2, float v3)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform3f(uniformId, v1, v2, v3);
}

void		Shader::sendUniformData(const char* varName, float v1, float v2, float v3, float v4)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform4f(uniformId, v1, v2, v3, v4);
}

void		Shader::sendUniformData(const char* varName, Vec3f const& vec)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform3fv(uniformId, 1, vec.get());
}

void		Shader::sendUniformData(const char* varName, Vec4f const& vec)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniform4fv(uniformId, 1, vec.get());
}

void		Shader::sendUniformData(const char* varName, Mat3f const& mat)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniformMatrix3fv(uniformId, 1, false, mat.get());
}

void		Shader::sendUniformData(const char* varName, Mat4f const& mat)
{
	GLuint	uniformId = glGetUniformLocation(this->_programId, varName);
	glUniformMatrix4fv(uniformId, 1, true, mat.get());
}

void		Shader::bindAttribLocation(const int index, const char* name)
{
	glBindAttribLocation(this->_programId, index, name);
}

int			Shader::getAttribLocation(const char* name)
{
	return glGetAttribLocation(this->_programId, name);
}